package com.zcr.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zcr.mapper.GonggaoMapper;
import com.zcr.pojo.Gonggao;
import com.zcr.service.GonggaoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @version 1.0
 * @author： 张诚
 * @date： 2021-03-13 11:34
 */
@Service("GonggaoService")
public class GonggaoServiceImpl extends ServiceImpl<GonggaoMapper, Gonggao> implements GonggaoService {

    @Resource
    private GonggaoMapper gonggaoMapper;


    @Override
    public List<Gonggao> getByGongGao(String shijian) {
        QueryWrapper<Gonggao> wrapper= Wrappers.query();
        wrapper.eq(!StringUtils.isBlank(shijian),"shijian",shijian);
        wrapper.orderByDesc("id");
        return gonggaoMapper.selectList(wrapper);
    }

    @Override
    public boolean addGongGao(Gonggao gonggao) {
        return  gonggaoMapper.insert(gonggao)>0;
    }

    public void deleteAllDruginfo(String[] ids) {
        gonggaoMapper.deleteBatchIds(Arrays.asList(ids));
    }

    @Override
    public boolean update(Gonggao gonggao) {
        return gonggaoMapper.updateById(gonggao)>0;
    }


}
